Create A/B Test
curl --request POST \
--url https://api.sophra.org/api/cortex/ab-test/create \
--header 'Content-Type: application/json' \
--data '
"{\n \"name\": \"{{variate_test_name}}\",\n \"description\": \"{{variate_test_description}}\",\n \"variants\": [\n {\n \"id\": \"{{variate_test_id}}\",\n \"name\": \"Control Group\",\n \"allocation\": {{variate_test_allocation}},\n \"weights\": {\n \"title\": {{variate_test_weights_title}},\n \"content\": {{variate_test_weights_content}}\n }\n },\n {\n \"id\": \"variant_a\",\n \"name\": \"{{variate_a}}\",\n \"allocation\": {{variate_test_allocation}},\n \"weights\": {\n \"title\": {{variate_test_weights_title}},\n \"content\": {{variate_test_weights_content}}\n }\n }\n ]\n}"
'import requests
url = "https://api.sophra.org/api/cortex/ab-test/create"
payload = "{
\"name\": \"{{variate_test_name}}\",
\"description\": \"{{variate_test_description}}\",
\"variants\": [
{
\"id\": \"{{variate_test_id}}\",
\"name\": \"Control Group\",
\"allocation\": {{variate_test_allocation}},
\"weights\": {
\"title\": {{variate_test_weights_title}},
\"content\": {{variate_test_weights_content}}
}
},
{
\"id\": \"variant_a\",
\"name\": \"{{variate_a}}\",
\"allocation\": {{variate_test_allocation}},
\"weights\": {
\"title\": {{variate_test_weights_title}},
\"content\": {{variate_test_weights_content}}
}
}
]
}"
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify('{\n "name": "{{variate_test_name}}",\n "description": "{{variate_test_description}}",\n "variants": [\n {\n "id": "{{variate_test_id}}",\n "name": "Control Group",\n "allocation": {{variate_test_allocation}},\n "weights": {\n "title": {{variate_test_weights_title}},\n "content": {{variate_test_weights_content}}\n }\n },\n {\n "id": "variant_a",\n "name": "{{variate_a}}",\n "allocation": {{variate_test_allocation}},\n "weights": {\n "title": {{variate_test_weights_title}},\n "content": {{variate_test_weights_content}}\n }\n }\n ]\n}')
};
fetch('https://api.sophra.org/api/cortex/ab-test/create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sophra.org/api/cortex/ab-test/create",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode('{
"name": "{{variate_test_name}}",
"description": "{{variate_test_description}}",
"variants": [
{
"id": "{{variate_test_id}}",
"name": "Control Group",
"allocation": {{variate_test_allocation}},
"weights": {
"title": {{variate_test_weights_title}},
"content": {{variate_test_weights_content}}
}
},
{
"id": "variant_a",
"name": "{{variate_a}}",
"allocation": {{variate_test_allocation}},
"weights": {
"title": {{variate_test_weights_title}},
"content": {{variate_test_weights_content}}
}
}
]
}'),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sophra.org/api/cortex/ab-test/create"
payload := strings.NewReader("\"{\\n \\\"name\\\": \\\"{{variate_test_name}}\\\",\\n \\\"description\\\": \\\"{{variate_test_description}}\\\",\\n \\\"variants\\\": [\\n {\\n \\\"id\\\": \\\"{{variate_test_id}}\\\",\\n \\\"name\\\": \\\"Control Group\\\",\\n \\\"allocation\\\": {{variate_test_allocation}},\\n \\\"weights\\\": {\\n \\\"title\\\": {{variate_test_weights_title}},\\n \\\"content\\\": {{variate_test_weights_content}}\\n }\\n },\\n {\\n \\\"id\\\": \\\"variant_a\\\",\\n \\\"name\\\": \\\"{{variate_a}}\\\",\\n \\\"allocation\\\": {{variate_test_allocation}},\\n \\\"weights\\\": {\\n \\\"title\\\": {{variate_test_weights_title}},\\n \\\"content\\\": {{variate_test_weights_content}}\\n }\\n }\\n ]\\n}\"")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sophra.org/api/cortex/ab-test/create")
.header("Content-Type", "application/json")
.body("\"{\\n \\\"name\\\": \\\"{{variate_test_name}}\\\",\\n \\\"description\\\": \\\"{{variate_test_description}}\\\",\\n \\\"variants\\\": [\\n {\\n \\\"id\\\": \\\"{{variate_test_id}}\\\",\\n \\\"name\\\": \\\"Control Group\\\",\\n \\\"allocation\\\": {{variate_test_allocation}},\\n \\\"weights\\\": {\\n \\\"title\\\": {{variate_test_weights_title}},\\n \\\"content\\\": {{variate_test_weights_content}}\\n }\\n },\\n {\\n \\\"id\\\": \\\"variant_a\\\",\\n \\\"name\\\": \\\"{{variate_a}}\\\",\\n \\\"allocation\\\": {{variate_test_allocation}},\\n \\\"weights\\\": {\\n \\\"title\\\": {{variate_test_weights_title}},\\n \\\"content\\\": {{variate_test_weights_content}}\\n }\\n }\\n ]\\n}\"")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sophra.org/api/cortex/ab-test/create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "\"{\\n \\\"name\\\": \\\"{{variate_test_name}}\\\",\\n \\\"description\\\": \\\"{{variate_test_description}}\\\",\\n \\\"variants\\\": [\\n {\\n \\\"id\\\": \\\"{{variate_test_id}}\\\",\\n \\\"name\\\": \\\"Control Group\\\",\\n \\\"allocation\\\": {{variate_test_allocation}},\\n \\\"weights\\\": {\\n \\\"title\\\": {{variate_test_weights_title}},\\n \\\"content\\\": {{variate_test_weights_content}}\\n }\\n },\\n {\\n \\\"id\\\": \\\"variant_a\\\",\\n \\\"name\\\": \\\"{{variate_a}}\\\",\\n \\\"allocation\\\": {{variate_test_allocation}},\\n \\\"weights\\\": {\\n \\\"title\\\": {{variate_test_weights_title}},\\n \\\"content\\\": {{variate_test_weights_content}}\\n }\\n }\\n ]\\n}\""
response = http.request(request)
puts response.read_bodyCortex > A/B Testing
Create A/B Test
POST
/
cortex
/
ab-test
/
create
Create A/B Test
curl --request POST \
--url https://api.sophra.org/api/cortex/ab-test/create \
--header 'Content-Type: application/json' \
--data '
"{\n \"name\": \"{{variate_test_name}}\",\n \"description\": \"{{variate_test_description}}\",\n \"variants\": [\n {\n \"id\": \"{{variate_test_id}}\",\n \"name\": \"Control Group\",\n \"allocation\": {{variate_test_allocation}},\n \"weights\": {\n \"title\": {{variate_test_weights_title}},\n \"content\": {{variate_test_weights_content}}\n }\n },\n {\n \"id\": \"variant_a\",\n \"name\": \"{{variate_a}}\",\n \"allocation\": {{variate_test_allocation}},\n \"weights\": {\n \"title\": {{variate_test_weights_title}},\n \"content\": {{variate_test_weights_content}}\n }\n }\n ]\n}"
'import requests
url = "https://api.sophra.org/api/cortex/ab-test/create"
payload = "{
\"name\": \"{{variate_test_name}}\",
\"description\": \"{{variate_test_description}}\",
\"variants\": [
{
\"id\": \"{{variate_test_id}}\",
\"name\": \"Control Group\",
\"allocation\": {{variate_test_allocation}},
\"weights\": {
\"title\": {{variate_test_weights_title}},
\"content\": {{variate_test_weights_content}}
}
},
{
\"id\": \"variant_a\",
\"name\": \"{{variate_a}}\",
\"allocation\": {{variate_test_allocation}},
\"weights\": {
\"title\": {{variate_test_weights_title}},
\"content\": {{variate_test_weights_content}}
}
}
]
}"
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify('{\n "name": "{{variate_test_name}}",\n "description": "{{variate_test_description}}",\n "variants": [\n {\n "id": "{{variate_test_id}}",\n "name": "Control Group",\n "allocation": {{variate_test_allocation}},\n "weights": {\n "title": {{variate_test_weights_title}},\n "content": {{variate_test_weights_content}}\n }\n },\n {\n "id": "variant_a",\n "name": "{{variate_a}}",\n "allocation": {{variate_test_allocation}},\n "weights": {\n "title": {{variate_test_weights_title}},\n "content": {{variate_test_weights_content}}\n }\n }\n ]\n}')
};
fetch('https://api.sophra.org/api/cortex/ab-test/create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.sophra.org/api/cortex/ab-test/create",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode('{
"name": "{{variate_test_name}}",
"description": "{{variate_test_description}}",
"variants": [
{
"id": "{{variate_test_id}}",
"name": "Control Group",
"allocation": {{variate_test_allocation}},
"weights": {
"title": {{variate_test_weights_title}},
"content": {{variate_test_weights_content}}
}
},
{
"id": "variant_a",
"name": "{{variate_a}}",
"allocation": {{variate_test_allocation}},
"weights": {
"title": {{variate_test_weights_title}},
"content": {{variate_test_weights_content}}
}
}
]
}'),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.sophra.org/api/cortex/ab-test/create"
payload := strings.NewReader("\"{\\n \\\"name\\\": \\\"{{variate_test_name}}\\\",\\n \\\"description\\\": \\\"{{variate_test_description}}\\\",\\n \\\"variants\\\": [\\n {\\n \\\"id\\\": \\\"{{variate_test_id}}\\\",\\n \\\"name\\\": \\\"Control Group\\\",\\n \\\"allocation\\\": {{variate_test_allocation}},\\n \\\"weights\\\": {\\n \\\"title\\\": {{variate_test_weights_title}},\\n \\\"content\\\": {{variate_test_weights_content}}\\n }\\n },\\n {\\n \\\"id\\\": \\\"variant_a\\\",\\n \\\"name\\\": \\\"{{variate_a}}\\\",\\n \\\"allocation\\\": {{variate_test_allocation}},\\n \\\"weights\\\": {\\n \\\"title\\\": {{variate_test_weights_title}},\\n \\\"content\\\": {{variate_test_weights_content}}\\n }\\n }\\n ]\\n}\"")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.sophra.org/api/cortex/ab-test/create")
.header("Content-Type", "application/json")
.body("\"{\\n \\\"name\\\": \\\"{{variate_test_name}}\\\",\\n \\\"description\\\": \\\"{{variate_test_description}}\\\",\\n \\\"variants\\\": [\\n {\\n \\\"id\\\": \\\"{{variate_test_id}}\\\",\\n \\\"name\\\": \\\"Control Group\\\",\\n \\\"allocation\\\": {{variate_test_allocation}},\\n \\\"weights\\\": {\\n \\\"title\\\": {{variate_test_weights_title}},\\n \\\"content\\\": {{variate_test_weights_content}}\\n }\\n },\\n {\\n \\\"id\\\": \\\"variant_a\\\",\\n \\\"name\\\": \\\"{{variate_a}}\\\",\\n \\\"allocation\\\": {{variate_test_allocation}},\\n \\\"weights\\\": {\\n \\\"title\\\": {{variate_test_weights_title}},\\n \\\"content\\\": {{variate_test_weights_content}}\\n }\\n }\\n ]\\n}\"")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sophra.org/api/cortex/ab-test/create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "\"{\\n \\\"name\\\": \\\"{{variate_test_name}}\\\",\\n \\\"description\\\": \\\"{{variate_test_description}}\\\",\\n \\\"variants\\\": [\\n {\\n \\\"id\\\": \\\"{{variate_test_id}}\\\",\\n \\\"name\\\": \\\"Control Group\\\",\\n \\\"allocation\\\": {{variate_test_allocation}},\\n \\\"weights\\\": {\\n \\\"title\\\": {{variate_test_weights_title}},\\n \\\"content\\\": {{variate_test_weights_content}}\\n }\\n },\\n {\\n \\\"id\\\": \\\"variant_a\\\",\\n \\\"name\\\": \\\"{{variate_a}}\\\",\\n \\\"allocation\\\": {{variate_test_allocation}},\\n \\\"weights\\\": {\\n \\\"title\\\": {{variate_test_weights_title}},\\n \\\"content\\\": {{variate_test_weights_content}}\\n }\\n }\\n ]\\n}\""
response = http.request(request)
puts response.read_bodyBody
application/json
The body is of type object.
Response
200 - application/json
Successful response

